package edu.scau.ojforwarder.controller;

import edu.scau.ojforwarder.bean.BaseResult;
import edu.scau.ojforwarder.bean.HduStatus;
import edu.scau.ojforwarder.bean.HduSubmission;
import edu.scau.ojforwarder.service.HduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hdu")
public class HduController {

    @Autowired
    private HduService hduService;

    @RequestMapping(value = "/submit", method = RequestMethod.POST)
    public BaseResult<HduStatus> submit(@RequestBody HduSubmission submission) {
        return hduService.addSubmission(submission);
    }

    @RequestMapping(value = "/status/{submissionId}", method = RequestMethod.GET)
    public BaseResult<HduStatus> getStatus(@PathVariable String submissionId) {
        return hduService.getStatus(submissionId);
    }

    @RequestMapping(value = "/problem-desc", method = RequestMethod.GET)
    public BaseResult<String> problemDesc(@RequestParam("cid") String cid,
                                          @RequestParam("pid") String pid) {
        return hduService.getProblemDesc(cid, pid);
    }
}
